<?php
namespace App\Models;

/**
 * 系统签署协议对象
 */
class MProtocols extends BaseModel
{
    public $table =  "protocols";

    /**
     * 信息存储验证
     * $flag 0 = rules  1 = msg
     */
    public static function editRulesWithMsg($flag)
    {
        $rules = array(
            "title"   => "required|max:255",
            'content' => 'required'
        );

        $msg = array(
            "title.required"   => "请必须填写协议名称！",
            "content.required" => "请必须填写完整的协议内容！"
        );

        if ($flag == 0) {
            return $rules;
        } else {
            return $msg;
        }
    }

    /**
     * 保存或更新
     */
    public function saveData($title, $content)
    {
        $this->title = $title;
        $this->content = $content;
        $this->time = time();
        return $this->save();
    }
}